<?php
// @formatter:off
/**
 * @file WCHoldersBus.php
 * @author Alejandro Dario Simi
 * @date $Date: 2014-05-04 01:33:52 +0000 (Sun, 04 May 2014) $
 *
 * $Id: WCHoldersBus.php 111 2014-05-04 01:33:52Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/includes/holders/WCHoldersBus.php $
 */
// @formatter:on

/**
 * @class WCHoldersBus
 */
class WCHoldersBus extends WCSingleton {
	/**
	 * @var WCHolder[]
	 */
	protected $_holders = array();
	//
	// Public methods.
	public function restrictGroup(WCGroup &$group) {
		foreach($this->_holders as $holder) {
			if(in_array('WCHolderGroupDependant', class_implements($holder))) {
				$holder->restrictGroup($group);
			}
		}
	}
	public function unrestrictGroups() {
		foreach($this->_holders as $holder) {
			if(in_array('WCHolderGroupDependant', class_implements($holder))) {
				$holder->unrestrictGroups();
			}
		}
	}
	//
	// Public class methods.
	public static function AddHolder(WCHolder &$holder) {
		$bus = WCHoldersBus::Instance();
		$c = get_class($holder);
		$bus->_holders[$c] = $holder;
	}
}

interface WCHolderGroupDependant {
	public function restrictGroup(WCGroup &$group);
	public function unrestrictGroups();
}
interface WCHolderKeywordDependant {
	public function restrictKeyword($keyword);
	public function unrestrictKeywords();
}
